﻿
Ext.define('SHApp.System.User.Grid1', {
    extend: 'Ext.panel.Panel',
    alias: 'shapp.system.user.grid',
    requires: ['SHApp.Sys.User.Grid', 'SHApp.Sys.Role.Grid1', 'SHApp.Sys.Department.Grid'],
    layout: { type: "border" },
    gUser: null,
    gRole: null,
    departMent: null,
    pvalue: 0,
    initComponent: function () {
        var me = this;
        Ext.apply(this);
        this.createItem(); //初始化分页条
        this.callParent(arguments);
    },
    createItem: function () {
        var me = this;
        var departMent = Ext.create("SHApp.Sys.Department.Grid", { title: "供应商管理", width: 200, pvalue: me.pvalue, split: true,
            region: "west"

        });
        departMent.on("selectionchange", function (model, records) {
            var departID = "";
            if (records.length > 0) {
                departID = records[0].data.id;
            }
            me.gUser.loadByDepartID(departID);

        });
        this.departMent = departMent;

        var grid = Ext.create("SHApp.Sys.User.Grid", { title: "用户管理", flex: 1, pvalue: me.pvalue,
            region: "center"

        });

        grid.on("selectionchange", function (model, records) {
            var userID = "";
            if (records.length > 0) {
                userID = records[0].data.Id;
                userName = records[0].data.Name;
            }
            me.gRole.loadByUserID(userID, userName);

        });

        this.gUser = grid;

        var grid1 = Ext.create("SHApp.Sys.Role.Grid1", {
            title: "角色分配",
            width: 140,
            split: true,
            region: "east",
            pvalue: me.pvalue
        });

        me.gRole = grid1;
        me.items = [me.departMent, me.gUser, me.gRole];
    }
})

